package cn.facetoken.homer;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {FaceSample.class}, version = 3)
public abstract class MainDatabase extends RoomDatabase {

    public abstract FaceSampleDao faceSampleDao();

    private static MainDatabase instance;

    public static MainDatabase getInstance(Context context) {
        if (null!=instance) {
            return instance;
        }

        synchronized (MainDatabase.class) {
            if (null==instance) {
                instance = Room.databaseBuilder(context, MainDatabase.class, "homer.db").addMigrations(Migration2.getInstance()).build();
                //instance = Room.databaseBuilder(context, MainDatabase.class, "homer.db").fallbackToDestructiveMigration().build();
            }
            return instance;
        }
    }
}
